import Map from '@/components/AMap';
import { useEffect, useRef } from 'react';
import styles from './index.less';

const TripGpsList = (props) => {
  const { data } = props;
  const map = useRef();
  useEffect(() => {
    (async () => {
      map.current = new Map({
        domId: 'trip_map',
      });
      await map.current.load();
      if (data && data.length) {
        const line = map.current.loadLine(data);
      }
      map.current.mapInstance.setFitView();
    })();
  }, [data]);
  return (
    <div className={styles.tripGpsList}>
      <div className={styles.tripMap} id="trip_map"></div>
    </div>
  );
};

export default TripGpsList;
